package cn.liukuan.jps.plugins;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.wltea.analyzer.lucene.IKTokenizer;

/**
 * Created by liukuan on 16/6/3.
 */
public class IKSameAnalyzer  extends Analyzer {

    private boolean useSmart;

    public boolean useSmart() {
        return this.useSmart;
    }

    public void setUseSmart(boolean useSmart) {
        this.useSmart = useSmart;
    }

    @Override
    protected TokenStreamComponents createComponents(String fieldName) {

        IKTokenizer _IKTokenizer = new IKTokenizer(this.useSmart());

        return new TokenStreamComponents(_IKTokenizer){
            @Override
            public TokenStream getTokenStream() {
                return new IKSameFilter(super.getTokenStream());
            }
        };
    }



}
